$(document).ready(function(){
//	modified by eric 2020/06/02 否则点击查询没反应
	$(".FSsearch").click(function(){
		var DepartureDate = $(".FSdate input").val();
		var page=0;
        pageObj.page=page;
        pageObj.DepartureDate=DepartureDate;
		searchUserList(DepartureDate,pageObj.page);
	});
	$(".chevron-right").click(function(){
    	if(pageObj.page<pageObj.pages-1){
    		searchUserList(pageObj.DepartureDate,++pageObj.page);
    	}
    	else{
    		alert("当前已经是最后一页");
    	}
    });
    $(".chevron-left").click(function(){
    	if(pageObj.page>0){
    		searchUserList(pageObj.DepartureDate,--pageObj.page);
    	}
    	else{
    		alert("当前已经是第一页");
    	}
    });  
    $(".step-forward").click(function(){
    	if(pageObj.page<pageObj.pages-1){
    		pageObj.page = pageObj.pages-1;
    		searchUserList(pageObj.DepartureDate,pageObj.page);
    	}
    });   
    $(".step-backward").click(function(){
    	if(pageObj.page>0){
    		pageObj.page =0;
    		searchUserList(pageObj.DepartureDate,pageObj.page);
    	}
    });
});

var pageObj={};  
function searchUserList(DepartureDate,page){
	$.ajax({ 
        type: "GET",
        url: "./GetFlightStatus", 
        data: "departureDate="+DepartureDate+"&startPage="+page,
        success: function(json){
        	var msg =JSON.parse(json);
        	$(".FSform table tbody tr").remove();
        	var html="";
        	if(msg!=null && msg.infoList.length>0){
                for(var i = 0; i< msg.infoList.length;i++){
                	var schedule = msg.infoList[i];
                	var tr="<tr class='tdcolor1'>" +
                	"<td>"+1+"</td>" +
        			"<td>"+schedule.FlightNumber+"</td>" +
        			"<td>"+schedule.departcityname+"/"+schedule.departcitycode+"</td>" +
        			"<td>"+schedule.arrivecityname+"/"+schedule.arrivecitycode+"</td>" +
        			"<td>"+schedule.date+"</td>" +
        			"<td>"+schedule.date+"</td>" +
        			"<td>"+schedule.date+"</td>" +
        			"<td>"+schedule.Gate+"</td>" +
        			"<td>"+schedule.date+"</td>" +
        			"</tr>";
                	html+=tr;
                }
        	}
//        	modified by eric 2020/06/02 否则点击查询没数据,原class是UMtab
        	$(".FSform table tbody").append(html);
        	pageObj.pageSize = msg.page.pageSize; 
            pageObj.total = msg.page.total; 
            pageObj.page = msg.page.page; 
            var pages=parseInt(pageObj.total/pageObj.pageSize);
            if(pageObj.total/pageObj.pageSize>pages){pages++;}
            pageObj.pages=pages;
            pageObj.DepartureDate=DepartureDate;
            $(".pagenum .pages").empty();
            for(i = 0; i<pages;i++){
            	if(i==pageObj.page){
            		$(".pagenum .pages").append("<option  value='"+i+"' selected>"+(i+1)+"</option>");
            	}
            	else{
            		$(".pagenum .pages").append("<option  value='"+i+"'>"+(i+1)+"</option>");
            	}
            }
            $(".pagess").text(pages); 
        } 
     });
}